{php include pubTemplate("header")}

<div class="container">

    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{SITE_URL}">首页</a></li>
            {if $strTopic['groupid']}
            <li class="breadcrumb-item"><a href="{tsUrl('group')}">小组</a></li>
            <li class="breadcrumb-item"><a href="{tsUrl('group','show',array('id'=>$strGroup['groupid']))}">{$strGroup['groupname']}</a></li>
            {else}
            <li class="breadcrumb-item"><a href="{tsUrl('topic')}">{$TS_APP['appname']}</a></li>
            {/if}
            <li class="breadcrumb-item active" aria-current="page">{$strTopic['title']}</li>
        </ol>
    </nav>


    <div class="row">

        <div class="col-md-8">



            <div class="card">
                <div class="card-body">


                    <h1 class="h5 pt-0 pb-3 font-weight-bold">{if $strTopic['label']}<span class="badge badge-danger fw300">{tsTitle($strTopic['label'])}</span>{/if}{if $strTopic['typeid'] !='0'}<a href="{tsUrl('group','show',array('id'=>$strTopic['groupid'],typeid=>$strTopic['typeid']))}">[{$strTopic['type']['typename']}]</a>{/if}{$strTopic['title']}</h1>


                    <div class="d-flex flex-row justify-content-between">


                        <div class="d-flex">


                            <div>
                                <a href="{tsUrl('user','space',array('id'=>$strTopic['user']['userid']))}">
                                    <img class="rounded-circle" title="{$strTopic['user']['username']}" alt="{$strTopic['user']['username']}" src="{$strTopic['user']['face']}" width="36" height="36">
                                </a>
                            </div>
                            <div class="ml-2">
                                <div class="fs14"><a href="{tsUrl('user','space',array('id'=>$strTopic['userid']))}">{$strTopic['user']['username']}</a></div>
                                <div class="c9 fs12">{php echo date('Y-m-d H:i:s',$strTopic['addtime'])}</div>
                            </div>


                        </div>



                        <div class="d-flex flex-row justify-content-end c9">

                            <div><i class="bi-chat-text"></i> {$strTopic['count_comment']}</div>
                            <div class="ml-3"><i class="bi bi-eye"></i> {$strTopic['count_view']}</div>

                        </div>
                    </div>





                    <div class="mb-3 mt-3">
                        {loop $strTopic[tags] $key $item}
                        <a class="badge badge-secondary fw300 mr-2" href="{tsUrl('topic','tag',array('id'=>urlencode($item['tagname'])))}">{$item['tagname']}</a>
                        {/loop}
                    </div>


                    {if $page == '1'}
                    <div class="topic-content">


                        {if $isread==1}
                        <div class="alert alert-info">查看帖子需要支付 <span class="text-danger">{$strTopic['score']}积分</span> <a class="btn btn-sm btn-success" href="javascript:void('0');" onclick="tsPost('index.php?app=topic&ac=score&ts=pay',{'topicid':'{$topicid}'})">支付</a></div>
                        {else}


                        <div class="topic-view common-content">
                            {$strTopic['content']}


                            {if $strTopic['photos']}
                                {loop $strTopic['photos'] $key $item}
                                <p class="tac"><img src="{$item}" alt="{$strTopic['title']}"></p>
                                {/loop}
                            {/if}



                            {if $strTopic['video']}
                            <p>
                                <video class="mw-100" controls="controls" src="{$strTopic['video']}"></video>
                            </p>
                            {/if}


                            {$tpUrl}
                        </div>



                        {/if}
                    </div>
                    {/if}



                    <!--帖子内容底部插件钩子-->
                    <div>{php doAction('topic_footer')}</div>

                    <div class="mt-3">{php doAction('gobad','468')}</div>



                    {if $TS_USER['userid'] == $strTopic['userid'] || $TS_USER['userid']==$strGroup['userid'] || $strGroupUser['isadmin']=='1' || $TS_USER['isadmin']=='1'}
                    <div class="btool mt-3">
                        {if $TS_USER['userid']==$strGroup['userid'] ||$strGroupUser['isadmin']=="1" || $TS_USER['isadmin']=="1"}


                        <a href="#" data-toggle="modal" data-target="#bookModal"><i class="bi bi-bookmark-check"></i> 标注</a>


                        <a href="javascript:void('0');" onclick="topicAudit('{$strTopic['topicid']}','{$_SESSION['token']}');">{if $strTopic['isaudit']=='1'}审核{else}取消审核{/if}</a>

                        <a href="{SITE_URL}index.php?app=topic&ac=ajax&ts=topic_istop&topicid={$strTopic['topicid']}">{if $strTopic['istop']=='0'}置顶{else}取消置顶{/if}</a>

                        <a href="javascript:void('0');" onclick="tsPost('index.php?app=topic&ac=ajax&ts=isrecommend&js=1',{'topicid':'{$strTopic['topicid']}'})">{if $strTopic['isrecommend']=='0'}推荐{else}取消推荐{/if}</a>

                        <a href="{SITE_URL}index.php?app=topic&ac=ajax&ts=isposts&topicid={$strTopic['topicid']}&token={$_SESSION['token']}">{if $strTopic['isposts']==0}精华{else}取消精华{/if}</a>

                        <a href="{SITE_URL}index.php?app=topic&ac=move&topicid={$strTopic['topicid']}">移动</a>

                        {/if}
                        <a href="{SITE_URL}index.php?app=topic&ac=edit&topicid={$strTopic['topicid']}">编辑</a>
                        <a href="{SITE_URL}index.php?app=topic&ac=delete&topicid={$strTopic['topicid']}&token={$_SESSION['token']}" onClick="return confirm('确定删除吗?')"><i class="bi bi-trash"></i> 删除</a>

                    </div>
                    {/if}


                </div>
            </div>



            <div class="card">
                <div class="card-header">评论{if $strTopic['count_comment']} <small class="text-secondary">({$strTopic['count_comment']})</small>{/if}</div>
                <div class="card-body">




                    <!--评论列表-->
                    {php include pubTemplate("comment")}





                    <div class="commentform">
                        
                        {if $strTopic[iscomment] == 1}
                        <div class="tac pd20 fw300 text-black-50">此内容暂不接受评论！</div>
                        {else}


                        
                            {if tsIntval($TS_USER[userid])==0}
                            <div class="tac pd20 fw300">
                                <a href="{tsUrl('user','login')}">登录</a> | <a href="{tsUrl('user','register')}">注册</a>
                            </div>
                            {else}

                            <form id="comm-form" method="post" action="{SITE_URL}index.php?app=comment&ac=add">
                                <div >
                                    <textarea id="tseditor" name="content"></textarea>
                                </div>
                                <div class="row mt-3">
                                    <div class="col-md-6">
                                        {if $TS_SITE['isauthcode']}
                                        <input class="form-control form-control-sm w-auto float-left" name="authcode" placeholder="输入验证码" />
                                        <img class="mt-1 ml-1" src="{tsUrl('pubs','code')}" onclick="javascript:newgdcode(this,this.src);" title="点击刷新验证码" alt="点击刷新验证码" style="cursor:pointer;"/>
                                        {/if}
                                    </div>
                                    <div class="col-md-4">
                                        <div class="mt-1">是否公开：<input type="radio" name="ispublic" value="0" checked />公开 <input type="radio" name="ispublic" value="1" />不公开</div>
                                    </div>
                                    <div class="col-md-2 text-right">
                                        <input type="hidden" name="ptable" value="topic">
                                        <input type="hidden" name="pkey" value="topicid">
                                        <input type="hidden" name="pid" value="{$strTopic['topicid']}" />
                                        <input type="hidden" name="token" value="{$_SESSION['token']}" />
                                        <button class="btn btn-sm btn-info btn-block" type="submit">提交评论</button>
                                    </div>
                                </div>
                            </form>
                            {/if}



                        {/if}
                    </div>

                </div>
            </div>

        </div>

        <div class="col-md-4">


            {php doAction('gobad','topic_right_top')}



            <div class="card">
                <div class="card-header">最新帖子</div>
                <div class="card-body commlist">
                    <ul>
                        {loop $newTopic $key $item}
                        <li>
                            <a href="{tsUrl('topic','show',array('id'=>$item[topicid]))}">{php echo tsTitle($item[title])}</a>
                        </li>
                        {/loop}
                    </ul>
                </div>
            </div>



            <div class="card">
                <div class="card-header">热门帖子</div>
                <div class="card-body commlist">
                    <ul>
                        {loop $arrHotTopic $key $item}
                        <li><a href="{tsUrl('topic','show',array('id'=>$item['topicid']))}">{$item['title']}</a></li>
                        {/loop}
                    </ul>
                </div>

            </div>



            <div class="clear"></div>
            <!--广告位-->
            {php doAction('gobad','300')}
        </div>

    </div>
</div>




<div class="modal fade" id="bookModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">标注</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label for="book-text" class="col-form-label">请输入标注内容(最多8个字符):</label>
                        <input type="text" value="{tsTitle($strTopic['label'])}" class="form-control" id="book-text">
                    </div>

                    <div class="form-group">
                        <div class="text-danger" id="book-alert"></div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-sm" onclick="toBook('{$topicid}')">提交</button>
            </div>
        </div>
    </div>
</div>
{php doAction('tseditor','mini')}
{php include pubTemplate("footer")}